
import React,{ Component } from 'react'
import {
    Text,
    View,
    Image,
    TouchableOpacity,
    StyleSheet,
    FlatList,
    Switch,
}from 'react-native'
import close from '../images/close.png'
import keting from '../images/keting.png'
import zhuwo from '../images/zhuwo.png'
import ciwo from '../images/ciwo.png'
import chufang from '../images/chufang.png'
import laorenjian from '../images/laoren.png'
import shufang from '../images/shufang.png'
import cheku from '../images/car.png'
var imagesArr=[close,keting,zhuwo,ciwo,chufang,laorenjian,shufang,cheku]
import BasePage from '../BasePage'
import NavigationBar from 'teaset/components/NavigationBar/NavigationBar';
import GateWayPage from './GateWay'
import Toast from 'teaset/components/Toast/Toast';
import CommonStyle from '../CommonStyle'
export default class LightManagermentSystemPage extends BasePage{
    renderNavigationBar(){
        return (
            <NavigationBar
                title={'灯管理系统'}
                rightView={<TouchableOpacity
                    onPress={()=>{
                        this.navigator.push({view:<GateWayPage/>});
                    }}
                >
                    <Image style={{width:32,height:32}} source={require('../images/add.png')}></Image>
                </TouchableOpacity>}
                backgroundColor='#4195D5'
                leftView={ <NavigationBar.BackButton  onPress={() => this.navigator.pop()} />}
            />
        );
    }
    renderPage(){
        return (
            <View style={{backgroundColor:'#f2f2f2',flex:1,marginTop:CommonStyle.statusBarAndNavigationBarH }}>
                <FlatList
                    data={[
                        {
                            roomType:'全部关闭',
                            key:1,
                            isOn:0
                        },{
                            roomType:'客    厅',
                            key:1,
                            isOn:1
                        },{
                            roomType:'主    室',
                            key:1,
                            isOn:0
                        },{
                            roomType:'次    卧',
                            key:1,
                            isOn:1
                        },{
                            roomType:'厨    房',
                            key:1,
                            isOn:0
                        },{
                            roomType:'老人房间',
                            key:1,
                            isOn:1
                        },{
                            roomType:'书    房',
                            key:1,
                            isOn:0
                        },{
                            roomType:'车    库',
                            key:1,
                            isOn:1
                        }
                        ]}
                    renderItem={this._renderItem}
                    keyExtractor={this._keyExtractor}
                />
            </View>
        );
    }
    _renderItem=({item,index})=>{
        return (
            <View style={{marginTop:10, height:50 ,backgroundColor:'white',flexDirection:'row'}}>
                <Image style={{marginTop:10, marginLeft:15, width:30, height:30 }} source={imagesArr[index]}/>
                <Text style={{marginLeft:15, marginTop:15 }}>{item.roomType}</Text>
                <Switch style={{position:'absolute', right:20, marginTop:10, }} value={false} onValueChange={(value)=>{
                   Toast.message('没有连接设备')
                }}></Switch>
            </View>
        );
    }
    _keyExtractor=({item,index})=>{
        return index;
    }

}
